// 第二个参数为是否包含子文件夹
const requireComponent = require.context('@/components/common', true, /\.vue|\.js$/);

const install = (Vue) => {
  requireComponent.keys().forEach(fileName => {
    const component = requireComponent(fileName);
    const componentName = component?.default?.name || fileName.replace(/^\.\/(.*)\/\w+\.\w+$/, '$1');
    Vue.component(componentName, component.default || component);
  });
};

export default {
  install
};
